﻿#region DaSampleParameter
/*----------------------------------------------------------------
// 文件名：DaSampleParameter.cs
// 功能描述：表dbo.Sample_Parameter的数据访问层
//
// 
// 创建时间：2009-11-20 DtataAccess template . Ver 5.0.20090413
//
// 修改标识： 
// 修改描述： 
//----------------------------------------------------------------*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Globalization;
using System.Text;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

using EQT.Model;


namespace EQT.Dal
{
    ///可以继承更上层接口,ISampleParameter ,数据访问层基类DaBase，
    ///DaBase中包含了DbException异常处理静态方法
    public partial class DaSampleParameter : DaBase<MoSampleParameter>
    {
        #region SQL const
        internal const string TABLE_COLUMNS = " SAMPLE_ID ,REPORT_ID ,REF_PAR_FILE ,MODEL ,EXFACTORY_ID ,EXFACTORY_DATE ,PRODUCER ,CONSIGN_CORP ,DELIVER_CORP ,TECH_CONDITION ,TEST_OUTLINE ,REG_DATE ,RATED_V ,RATED_A ,RESIST_A ,APEX_A ,COMMISSARY ,CREATE_TIME ,UPDATE_TIME   ";

        internal const string SQL_INSERT = "INSERT INTO SAMPLE_PARAMETER (" + TABLE_COLUMNS + ") VALUES (@SampleId,@ReportId,@RefParFile,@Model,@ExfactoryId,@ExfactoryDate,@Producer,@ConsignCorp,@DeliverCorp,@TechCondition,@TestOutline,@RegDate,@RatedV,@RatedA,@ResistA,@ApexA,@Commissary,@CreateTime,@UpdateTime)";
        internal const string SQL_SELECT = "SELECT " + TABLE_COLUMNS + " FROM SAMPLE_PARAMETER  ";
        internal const string SQL_SELECT_ONE = SQL_SELECT + " WHERE SAMPLE_ID=@SampleId";

        internal const string SQL_EXIST = "SELECT COUNT(*) FROM SAMPLE_PARAMETER  WHERE SAMPLE_ID=@SampleId  ";
        internal const string SQL_UPDATE = "UPDATE SAMPLE_PARAMETER SET REPORT_ID=@ReportId, REF_PAR_FILE=@RefParFile, MODEL=@Model, EXFACTORY_ID=@ExfactoryId, EXFACTORY_DATE=@ExfactoryDate, PRODUCER=@Producer, CONSIGN_CORP=@ConsignCorp, DELIVER_CORP=@DeliverCorp, TECH_CONDITION=@TechCondition, TEST_OUTLINE=@TestOutline, REG_DATE=@RegDate, RATED_V=@RatedV, RATED_A=@RatedA, RESIST_A=@ResistA, APEX_A=@ApexA, COMMISSARY=@Commissary, CREATE_TIME=@CreateTime, UPDATE_TIME=@UpdateTime WHERE SAMPLE_ID=@SampleId";

        internal const string SQL_DELETE_DEFAULT = "DELETE FROM SAMPLE_PARAMETER ";
        internal const string SQL_DELETE = "DELETE FROM SAMPLE_PARAMETER WHERE SAMPLE_ID=@SampleId";

        internal const string SQL_COUNT = "SELECT COUNT(*) FROM Sample_Parameter ";
        #endregion

        #region Constructor

        /// <summary>
        /// 默认构造函数，使用配置文件中默认的数据库配置。
        /// </summary>
        public DaSampleParameter()
        {
            this.db = DatabaseFactory.CreateDatabase();
        }
        /// <summary>
        /// 使用指定的databaseName数据库配置。
        /// </summary>
        /// <param name="databaseName">配置文件中数据库的配置名称。</param>
        public DaSampleParameter(string databaseName)
        {
            this.db = DatabaseFactory.CreateDatabase(databaseName);
        }

        public DaSampleParameter(Database db)
        {
            this.db = db;
        }

        #endregion

        //以下是CRUD方法，每个方法都有引入外部事务的版本

        #region 构造器模块

        internal override MoSampleParameter ConstructT()
        {
            return new MoSampleParameter();
        }
        #endregion



        #region Add模块 Helper

        ///build the command object.It never throw exception.
        internal override DbCommand ConstructAddCommand(Database db)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_INSERT);

            db.AddInParameter(dbCommand, "SampleId", DbType.AnsiString);
            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString);
            db.AddInParameter(dbCommand, "RefParFile", DbType.String);
            db.AddInParameter(dbCommand, "Model", DbType.String);
            db.AddInParameter(dbCommand, "ExfactoryId", DbType.String);
            db.AddInParameter(dbCommand, "ExfactoryDate", DbType.DateTime);
            db.AddInParameter(dbCommand, "Producer", DbType.String);
            db.AddInParameter(dbCommand, "ConsignCorp", DbType.String);
            db.AddInParameter(dbCommand, "DeliverCorp", DbType.String);
            db.AddInParameter(dbCommand, "TechCondition", DbType.String);
            db.AddInParameter(dbCommand, "TestOutline", DbType.String);
            db.AddInParameter(dbCommand, "RegDate", DbType.DateTime);
            db.AddInParameter(dbCommand, "RatedV", DbType.Decimal);
            db.AddInParameter(dbCommand, "RatedA", DbType.Decimal);
            db.AddInParameter(dbCommand, "ResistA", DbType.Decimal);
            db.AddInParameter(dbCommand, "ApexA", DbType.Decimal);
            db.AddInParameter(dbCommand, "Commissary", DbType.String);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime);
            return dbCommand;
        }
        internal override DbCommand ConstructAddCommand(Database db, MoSampleParameter entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_INSERT);
            db.AddInParameter(dbCommand, "SampleId", DbType.AnsiString, entity.SampleId);
            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString, entity.ReportId);
            db.AddInParameter(dbCommand, "RefParFile", DbType.String, entity.RefParFile);
            db.AddInParameter(dbCommand, "Model", DbType.String, entity.Model);
            db.AddInParameter(dbCommand, "ExfactoryId", DbType.String, entity.ExfactoryId);
            db.AddInParameter(dbCommand, "ExfactoryDate", DbType.DateTime, entity.ExfactoryDate);
            db.AddInParameter(dbCommand, "Producer", DbType.String, entity.Producer);
            db.AddInParameter(dbCommand, "ConsignCorp", DbType.String, entity.ConsignCorp);
            db.AddInParameter(dbCommand, "DeliverCorp", DbType.String, entity.DeliverCorp);
            db.AddInParameter(dbCommand, "TechCondition", DbType.String, entity.TechCondition);
            db.AddInParameter(dbCommand, "TestOutline", DbType.String, entity.TestOutline);
            db.AddInParameter(dbCommand, "RegDate", DbType.DateTime, entity.RegDate);
            db.AddInParameter(dbCommand, "RatedV", DbType.Decimal, entity.RatedV);
            db.AddInParameter(dbCommand, "RatedA", DbType.Decimal, entity.RatedA);
            db.AddInParameter(dbCommand, "ResistA", DbType.Decimal, entity.ResistA);
            db.AddInParameter(dbCommand, "ApexA", DbType.Decimal, entity.ApexA);
            db.AddInParameter(dbCommand, "Commissary", DbType.String, entity.Commissary);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, entity.CreateTime);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, entity.UpdateTime);
            return dbCommand;
        }

        internal override DbCommand PopulateAddCommandParameters(Database db, DbCommand addCmd, MoSampleParameter entity)
        {
            db.SetParameterValue(addCmd, "SampleId", entity.SampleId);
            db.SetParameterValue(addCmd, "ReportId", entity.ReportId);
            db.SetParameterValue(addCmd, "RefParFile", entity.RefParFile);
            db.SetParameterValue(addCmd, "Model", entity.Model);
            db.SetParameterValue(addCmd, "ExfactoryId", entity.ExfactoryId);
            db.SetParameterValue(addCmd, "ExfactoryDate", entity.ExfactoryDate);
            db.SetParameterValue(addCmd, "Producer", entity.Producer);
            db.SetParameterValue(addCmd, "ConsignCorp", entity.ConsignCorp);
            db.SetParameterValue(addCmd, "DeliverCorp", entity.DeliverCorp);
            db.SetParameterValue(addCmd, "TechCondition", entity.TechCondition);
            db.SetParameterValue(addCmd, "TestOutline", entity.TestOutline);
            db.SetParameterValue(addCmd, "RegDate", entity.RegDate);
            db.SetParameterValue(addCmd, "RatedV", entity.RatedV);
            db.SetParameterValue(addCmd, "RatedA", entity.RatedA);
            db.SetParameterValue(addCmd, "ResistA", entity.ResistA);
            db.SetParameterValue(addCmd, "ApexA", entity.ApexA);
            db.SetParameterValue(addCmd, "Commissary", entity.Commissary);
            db.SetParameterValue(addCmd, "CreateTime", entity.CreateTime);
            db.SetParameterValue(addCmd, "UpdateTime", entity.UpdateTime);
            return addCmd;
        }

        internal override DbCommand PopulateAddCommandParameters(Database db, DbCommand addCmd, DataRow row)
        {
            db.SetParameterValue(addCmd, "SampleId", row["SampleId"]);
            db.SetParameterValue(addCmd, "ReportId", row["ReportId"]);
            db.SetParameterValue(addCmd, "RefParFile", row["RefParFile"]);
            db.SetParameterValue(addCmd, "Model", row["Model"]);
            db.SetParameterValue(addCmd, "ExfactoryId", row["ExfactoryId"]);
            db.SetParameterValue(addCmd, "ExfactoryDate", row["ExfactoryDate"]);
            db.SetParameterValue(addCmd, "Producer", row["Producer"]);
            db.SetParameterValue(addCmd, "ConsignCorp", row["ConsignCorp"]);
            db.SetParameterValue(addCmd, "DeliverCorp", row["DeliverCorp"]);
            db.SetParameterValue(addCmd, "TechCondition", row["TechCondition"]);
            db.SetParameterValue(addCmd, "TestOutline", row["TestOutline"]);
            db.SetParameterValue(addCmd, "RegDate", row["RegDate"]);
            db.SetParameterValue(addCmd, "RatedV", row["RatedV"]);
            db.SetParameterValue(addCmd, "RatedA", row["RatedA"]);
            db.SetParameterValue(addCmd, "ResistA", row["ResistA"]);
            db.SetParameterValue(addCmd, "ApexA", row["ApexA"]);
            db.SetParameterValue(addCmd, "Commissary", row["Commissary"]);
            db.SetParameterValue(addCmd, "CreateTime", row["CreateTime"]);
            db.SetParameterValue(addCmd, "UpdateTime", row["UpdateTime"]);
            return addCmd;
        }

        #endregion

        #region Update模块 Helper

        internal override DbCommand ConstructUpdateCommand(Database db)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_UPDATE);
            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString);
            db.AddInParameter(dbCommand, "RefParFile", DbType.String);
            db.AddInParameter(dbCommand, "Model", DbType.String);
            db.AddInParameter(dbCommand, "ExfactoryId", DbType.String);
            db.AddInParameter(dbCommand, "ExfactoryDate", DbType.DateTime);
            db.AddInParameter(dbCommand, "Producer", DbType.String);
            db.AddInParameter(dbCommand, "ConsignCorp", DbType.String);
            db.AddInParameter(dbCommand, "DeliverCorp", DbType.String);
            db.AddInParameter(dbCommand, "TechCondition", DbType.String);
            db.AddInParameter(dbCommand, "TestOutline", DbType.String);
            db.AddInParameter(dbCommand, "RegDate", DbType.DateTime);
            db.AddInParameter(dbCommand, "RatedV", DbType.Decimal);
            db.AddInParameter(dbCommand, "RatedA", DbType.Decimal);
            db.AddInParameter(dbCommand, "ResistA", DbType.Decimal);
            db.AddInParameter(dbCommand, "ApexA", DbType.Decimal);
            db.AddInParameter(dbCommand, "Commissary", DbType.String);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime);
            db.AddInParameter(dbCommand, "SampleId", DbType.AnsiString);

            return dbCommand;
        }
        internal override DbCommand ConstructUpdateCommand(Database db, MoSampleParameter entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_UPDATE);
            db.AddInParameter(dbCommand, "ReportId", DbType.AnsiString, entity.ReportId);
            db.AddInParameter(dbCommand, "RefParFile", DbType.String, entity.RefParFile);
            db.AddInParameter(dbCommand, "Model", DbType.String, entity.Model);
            db.AddInParameter(dbCommand, "ExfactoryId", DbType.String, entity.ExfactoryId);
            db.AddInParameter(dbCommand, "ExfactoryDate", DbType.DateTime, entity.ExfactoryDate);
            db.AddInParameter(dbCommand, "Producer", DbType.String, entity.Producer);
            db.AddInParameter(dbCommand, "ConsignCorp", DbType.String, entity.ConsignCorp);
            db.AddInParameter(dbCommand, "DeliverCorp", DbType.String, entity.DeliverCorp);
            db.AddInParameter(dbCommand, "TechCondition", DbType.String, entity.TechCondition);
            db.AddInParameter(dbCommand, "TestOutline", DbType.String, entity.TestOutline);
            db.AddInParameter(dbCommand, "RegDate", DbType.DateTime, entity.RegDate);
            db.AddInParameter(dbCommand, "RatedV", DbType.Decimal, entity.RatedV);
            db.AddInParameter(dbCommand, "RatedA", DbType.Decimal, entity.RatedA);
            db.AddInParameter(dbCommand, "ResistA", DbType.Decimal, entity.ResistA);
            db.AddInParameter(dbCommand, "ApexA", DbType.Decimal, entity.ApexA);
            db.AddInParameter(dbCommand, "Commissary", DbType.String, entity.Commissary);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, entity.CreateTime);
            db.AddInParameter(dbCommand, "UpdateTime", DbType.DateTime, entity.UpdateTime);
            db.AddInParameter(dbCommand, "SampleId", DbType.AnsiString, entity.SampleId);

            return dbCommand;
        }

        internal override DbCommand PopulateUpdateCommandParameters(Database db, DbCommand updateCmd, MoSampleParameter entity)
        {
            db.SetParameterValue(updateCmd, "ReportId", entity.ReportId);
            db.SetParameterValue(updateCmd, "RefParFile", entity.RefParFile);
            db.SetParameterValue(updateCmd, "Model", entity.Model);
            db.SetParameterValue(updateCmd, "ExfactoryId", entity.ExfactoryId);
            db.SetParameterValue(updateCmd, "ExfactoryDate", entity.ExfactoryDate);
            db.SetParameterValue(updateCmd, "Producer", entity.Producer);
            db.SetParameterValue(updateCmd, "ConsignCorp", entity.ConsignCorp);
            db.SetParameterValue(updateCmd, "DeliverCorp", entity.DeliverCorp);
            db.SetParameterValue(updateCmd, "TechCondition", entity.TechCondition);
            db.SetParameterValue(updateCmd, "TestOutline", entity.TestOutline);
            db.SetParameterValue(updateCmd, "RegDate", entity.RegDate);
            db.SetParameterValue(updateCmd, "RatedV", entity.RatedV);
            db.SetParameterValue(updateCmd, "RatedA", entity.RatedA);
            db.SetParameterValue(updateCmd, "ResistA", entity.ResistA);
            db.SetParameterValue(updateCmd, "ApexA", entity.ApexA);
            db.SetParameterValue(updateCmd, "Commissary", entity.Commissary);
            db.SetParameterValue(updateCmd, "CreateTime", entity.CreateTime);
            db.SetParameterValue(updateCmd, "UpdateTime", entity.UpdateTime);
            db.SetParameterValue(updateCmd, "SampleId", entity.SampleId);
            return updateCmd;
        }
        internal override DbCommand PopulateUpdateCommandParameters(Database db, DbCommand updateCmd, DataRow row)
        {
            db.SetParameterValue(updateCmd, "ReportId", row["ReportId"]);
            db.SetParameterValue(updateCmd, "RefParFile", row["RefParFile"]);
            db.SetParameterValue(updateCmd, "Model", row["Model"]);
            db.SetParameterValue(updateCmd, "ExfactoryId", row["ExfactoryId"]);
            db.SetParameterValue(updateCmd, "ExfactoryDate", row["ExfactoryDate"]);
            db.SetParameterValue(updateCmd, "Producer", row["Producer"]);
            db.SetParameterValue(updateCmd, "ConsignCorp", row["ConsignCorp"]);
            db.SetParameterValue(updateCmd, "DeliverCorp", row["DeliverCorp"]);
            db.SetParameterValue(updateCmd, "TechCondition", row["TechCondition"]);
            db.SetParameterValue(updateCmd, "TestOutline", row["TestOutline"]);
            db.SetParameterValue(updateCmd, "RegDate", row["RegDate"]);
            db.SetParameterValue(updateCmd, "RatedV", row["RatedV"]);
            db.SetParameterValue(updateCmd, "RatedA", row["RatedA"]);
            db.SetParameterValue(updateCmd, "ResistA", row["ResistA"]);
            db.SetParameterValue(updateCmd, "ApexA", row["ApexA"]);
            db.SetParameterValue(updateCmd, "Commissary", row["Commissary"]);
            db.SetParameterValue(updateCmd, "CreateTime", row["CreateTime"]);
            db.SetParameterValue(updateCmd, "UpdateTime", row["UpdateTime"]);
            db.SetParameterValue(updateCmd, "SampleId", row["SampleId"]);
            return updateCmd;
        }

        internal override void PrepareDataAdapterCommand(Database db, out DbCommand dbInsertCommand,
                             out DbCommand dbUpdateCommand, out DbCommand dbDeleteCommand)
        {
            dbInsertCommand = db.GetSqlStringCommand(SQL_INSERT);
            #region set insert cmd parameters
            db.AddInParameter(dbInsertCommand, "SampleId", DbType.AnsiString, "SAMPLE_ID", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ReportId", DbType.AnsiString, "REPORT_ID", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "RefParFile", DbType.String, "REF_PAR_FILE", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Model", DbType.String, "MODEL", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ExfactoryId", DbType.String, "EXFACTORY_ID", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ExfactoryDate", DbType.DateTime, "EXFACTORY_DATE", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Producer", DbType.String, "PRODUCER", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ConsignCorp", DbType.String, "CONSIGN_CORP", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "DeliverCorp", DbType.String, "DELIVER_CORP", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "TechCondition", DbType.String, "TECH_CONDITION", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "TestOutline", DbType.String, "TEST_OUTLINE", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "RegDate", DbType.DateTime, "REG_DATE", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "RatedV", DbType.Decimal, "RATED_V", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "RatedA", DbType.Decimal, "RATED_A", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ResistA", DbType.Decimal, "RESIST_A", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "ApexA", DbType.Decimal, "APEX_A", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "Commissary", DbType.String, "COMMISSARY", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "CreateTime", DbType.DateTime, "CREATE_TIME", DataRowVersion.Current);
            db.AddInParameter(dbInsertCommand, "UpdateTime", DbType.DateTime, "UPDATE_TIME", DataRowVersion.Current);
            #endregion
            dbUpdateCommand = db.GetSqlStringCommand(SQL_UPDATE);
            #region Set update cmd value parameters
            db.AddInParameter(dbUpdateCommand, "ReportId", DbType.AnsiString, "REPORT_ID", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "RefParFile", DbType.String, "REF_PAR_FILE", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Model", DbType.String, "MODEL", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "ExfactoryId", DbType.String, "EXFACTORY_ID", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "ExfactoryDate", DbType.DateTime, "EXFACTORY_DATE", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Producer", DbType.String, "PRODUCER", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "ConsignCorp", DbType.String, "CONSIGN_CORP", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "DeliverCorp", DbType.String, "DELIVER_CORP", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "TechCondition", DbType.String, "TECH_CONDITION", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "TestOutline", DbType.String, "TEST_OUTLINE", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "RegDate", DbType.DateTime, "REG_DATE", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "RatedV", DbType.Decimal, "RATED_V", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "RatedA", DbType.Decimal, "RATED_A", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "ResistA", DbType.Decimal, "RESIST_A", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "ApexA", DbType.Decimal, "APEX_A", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "Commissary", DbType.String, "COMMISSARY", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "CreateTime", DbType.DateTime, "CREATE_TIME", DataRowVersion.Current);
            db.AddInParameter(dbUpdateCommand, "UpdateTime", DbType.DateTime, "UPDATE_TIME", DataRowVersion.Current);
            #endregion
            #region set update cmd pk where parameters
            db.AddInParameter(dbUpdateCommand, "SampleId", DbType.AnsiString, "SAMPLE_ID", DataRowVersion.Current);
            #endregion
            dbDeleteCommand = db.GetSqlStringCommand(SQL_DELETE);
            #region set delete cmd pk where parameters
            db.AddInParameter(dbDeleteCommand, "SampleId", DbType.AnsiString, "SAMPLE_ID", DataRowVersion.Current);
            #endregion
        }
        #endregion

        #region Delete模块 Helper

        internal override DbCommand ConstructDeleteCommand(Database db)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_DELETE);

            db.AddInParameter(dbCommand, "SampleId", DbType.AnsiString);

            return dbCommand;
        }
        internal override DbCommand ConstructDeleteCommand(Database db, MoSampleParameter entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_DELETE);

            db.AddInParameter(dbCommand, "SampleId", DbType.AnsiString, entity.SampleId);

            return dbCommand;
        }

        internal override DbCommand ConstructDeleteCommandForWhere(Database db, string where)
        {
            return db.GetSqlStringCommand(SQL_DELETE_DEFAULT + where);
        }

        internal override DbCommand PopulateDeleteCommandParameters(Database db, DbCommand deleteCmd, MoSampleParameter entity)
        {
            db.SetParameterValue(deleteCmd, "SampleId", entity.SampleId);
            return deleteCmd;
        }

        internal override DbCommand PopulateDeleteCommandParameters(Database db, DbCommand deleteCmd, DataRow row)
        {
            db.SetParameterValue(deleteCmd, "SampleId", row["SampleId"]);
            return deleteCmd;
        }

        #endregion helper

        #region Query模块 Helper

        internal override DbCommand ConstructQueryCommand(string condition)
        {
            return db.GetSqlStringCommand(SQL_SELECT + condition);
        }

        #endregion

        #region GetEntity(s)模块 Helper

        internal override DbCommand ConstructSelectOneCommand(Database db, MoSampleParameter entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_SELECT_ONE);

            db.AddInParameter(dbCommand, "SampleId", DbType.AnsiString, entity.SampleId);
            return dbCommand;
        }

        internal override void PopulateEntityByDataReader(IDataReader reader, ref MoSampleParameter entity)
        {
            if (!reader.IsDBNull(0)) entity.SampleId = reader.GetString(0);
            if (!reader.IsDBNull(1)) entity.ReportId = reader.GetString(1);
            if (!reader.IsDBNull(2)) entity.RefParFile = reader.GetString(2);
            if (!reader.IsDBNull(3)) entity.Model = reader.GetString(3);
            if (!reader.IsDBNull(4)) entity.ExfactoryId = reader.GetString(4);
            if (!reader.IsDBNull(5)) entity.ExfactoryDate = reader.GetDateTime(5);
            if (!reader.IsDBNull(6)) entity.Producer = reader.GetString(6);
            if (!reader.IsDBNull(7)) entity.ConsignCorp = reader.GetString(7);
            if (!reader.IsDBNull(8)) entity.DeliverCorp = reader.GetString(8);
            if (!reader.IsDBNull(9)) entity.TechCondition = reader.GetString(9);
            if (!reader.IsDBNull(10)) entity.TestOutline = reader.GetString(10);
            if (!reader.IsDBNull(11)) entity.RegDate = reader.GetDateTime(11);
            if (!reader.IsDBNull(12)) entity.RatedV = reader.GetDecimal(12);
            if (!reader.IsDBNull(13)) entity.RatedA = reader.GetDecimal(13);
            if (!reader.IsDBNull(14)) entity.ResistA = reader.GetDecimal(14);
            if (!reader.IsDBNull(15)) entity.ApexA = reader.GetDecimal(15);
            if (!reader.IsDBNull(16)) entity.Commissary = reader.GetString(16);
            if (!reader.IsDBNull(17)) entity.CreateTime = reader.GetDateTime(17);
            if (!reader.IsDBNull(18)) entity.UpdateTime = reader.GetDateTime(18);
        }



        internal override DbCommand ConstructSelectConditionCommand(Database db, string condition)
        {
            return db.GetSqlStringCommand(SQL_SELECT + condition);
        }

        #endregion

        #region Count模块 Helper

        internal override DbCommand ConstructCountCommand(Database db)
        {
            return db.GetSqlStringCommand(SQL_COUNT);
        }

        internal override DbCommand ConstructCountConditionCommand(Database db, string condition)
        {
            return db.GetSqlStringCommand(SQL_COUNT + condition);
        }

        #endregion

        #region IsExist模块 Helper

        internal override DbCommand ConstructIsExistCommand(Database db, MoSampleParameter entity)
        {
            DbCommand dbCommand = db.GetSqlStringCommand(SQL_EXIST);
            db.AddInParameter(dbCommand, "SampleId", DbType.AnsiString, entity.SampleId);
            return dbCommand;
        }

        #endregion



    }
}
#endregion

